Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fastify/busboy

Package Overview
Dependencies
Maintainers
17
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fastify/busboy

A streaming parser for HTML form data for node.js

  • 1.2.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
17
Created

What is @fastify/busboy?

The @fastify/busboy package is a plugin for the Fastify web framework. It is primarily used for handling multipart/form-data, which is often used for uploading files through HTTP forms. It wraps the busboy library, providing an easy-to-use interface for parsing form submissions, especially file uploads, within Fastify applications.

What are @fastify/busboy's main functionalities?

File Upload

This feature allows for handling file uploads in a Fastify application. The code demonstrates how to register the @fastify/busboy plugin and set up a route to handle POST requests for file uploads. The multipart method is used to process the incoming file stream.

fastify.register(require('@fastify/busboy'));

fastify.post('/upload', function (req, reply) {
  const mp = req.multipart(handler, function (err) {
    console.log('upload completed');
    reply.code(200).send();
  });

  function handler (field, file, filename, encoding, mimetype) {
    // Perform actions with the file stream
  }
});

Field Parsing

This feature is used for parsing non-file fields from a multipart/form-data request. The example shows how to collect form fields into an object and handle the form parsing completion.

fastify.register(require('@fastify/busboy'));

fastify.post('/form', function (req, reply) {
  const data = {};
  const mp = req.multipart(function (field, value) {
    data[field] = value;
  }, function (err) {
    console.log('form parsing completed', data);
    reply.code(200).send(data);
  }, { limits: { fields: 5 } });
});

Other packages similar to @fastify/busboy

Keywords

FAQs

Package last updated on 08 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc